package com.thwj.project.app.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.thwj.framework.web.domain.R;
import com.thwj.project.biz.domain.Banner;
import com.thwj.project.biz.service.IBannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags="app广告banner")
@RestController
@RequestMapping("/app/banner")
public class AppBannerController {


    @Autowired
    private IBannerService bannerService;


    @ApiOperation("获取广告banner列表")
    @GetMapping("/getBannerList")
    public R<List<Banner>> getBannerList(@RequestParam(defaultValue = "1",required = false) Integer position) {
        // 获取满足条件的banner列表
        List<Banner> bannerList = bannerService.list(new QueryWrapper<Banner>().eq("banner_position", position));
        return R.data(bannerList);
    }
}
